package com.lmx.repoDomain.tmodel;

import java.util.List;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.ForeignKey;
import javax.persistence.JoinColumn;
import javax.persistence.JoinTable;
import javax.persistence.ManyToMany;
import javax.persistence.ManyToOne;
import javax.persistence.Table;

import org.hibernate.annotations.Cache;
import org.hibernate.annotations.CacheConcurrencyStrategy;
import org.hibernate.annotations.Fetch;
import org.hibernate.annotations.FetchMode;

import com.lmx.repoDomain.tmodel.business.User;

import io.katharsis.resource.annotations.JsonApiIncludeByDefault;
import io.katharsis.resource.annotations.JsonApiResource;
import io.katharsis.resource.annotations.JsonApiToMany;
import io.katharsis.resource.annotations.JsonApiToOne;

/**
 * 班次设置表
 */
@JsonApiResource(type = "worktimesetting")
@Table(name = "tnb_worktimesetting")
@Entity
@Cache(usage = CacheConcurrencyStrategy.NONSTRICT_READ_WRITE)
public class WorkTimeSetting extends BaseEntity {

	private User lastUpdateUser;// 更新操作者userid

	private Integer createDateTime;// 创建时间

	private User createUser;

	private Integer lastUpdateDateTime;// 更新时间

	private String remark;// 备注

	private String startTime;// jihua时间

	private String endTime;// 计划时间

	private String name;// 时间

	private Dicttype colorFlag;

	private Integer startTimeInt;

	private Integer endTimeInt;
	
	private List<BedWorkTimeSetting> beds;
	
	private Integer ktFlag;
	
	@Column(name = "kt_flag")
	public Integer getKtFlag() {
		return ktFlag;
	}

	public void setKtFlag(Integer ktFlag) {
		this.ktFlag = ktFlag;
	}

	@ManyToMany(fetch = FetchType.EAGER, cascade = CascadeType.REFRESH)
	@JoinTable(name = "rel_worktimesetting_bed", joinColumns = {
			@JoinColumn(name = "setting_id", nullable = false, updatable = false, foreignKey = @ForeignKey(name = "null")) }, inverseJoinColumns = {
					@JoinColumn(name = "bed_id", nullable = false, updatable = false, foreignKey = @ForeignKey(name = "null")) })
	@Fetch(FetchMode.JOIN)
	@JsonApiToMany
	public List<BedWorkTimeSetting> getBeds() {
		return beds;
	}

	public void setBeds(List<BedWorkTimeSetting> beds) {
		this.beds = beds;
	}

	@JsonApiToOne
	@JsonApiIncludeByDefault
	@ManyToOne(fetch = FetchType.LAZY, cascade = CascadeType.REFRESH)
	@Fetch(FetchMode.JOIN)
	@JoinColumn(name = "color_id", foreignKey = @ForeignKey(name = "null"))
	public Dicttype getColorFlag() {
		return colorFlag;
	}

	public void setColorFlag(Dicttype colorFlag) {
		this.colorFlag = colorFlag;
	}

	@Column(name = "name")
	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	@Column(name = "starttime")
	public String getStartTime() {
		return startTime;
	}

	public void setStartTime(String startTime) {
		this.startTime = startTime;
	}

	@Column(name = "endtime")
	public String getEndTime() {
		return endTime;
	}

	public void setEndTime(String endTime) {
		this.endTime = endTime;
	}

	// @JsonApiToOne
	// @JsonApiIncludeByDefault
	// @Fetch(FetchMode.JOIN)
	// @ManyToOne(fetch = FetchType.LAZY, cascade = CascadeType.REFRESH)
	// @JoinColumn(name = "item_id",foreignKey = @ForeignKey(name = "null"))
	// public CustomerServiceItem getItem() {
	// return item;
	// }
	//
	// public void setItem(CustomerServiceItem item) {
	// this.item = item;
	// }

	@Column(name = "createDateTime")
	public Integer getCreateDateTime() {
		return createDateTime;
	}

	public void setCreateDateTime(Integer createDateTime) {
		this.createDateTime = createDateTime;
	}

	@Column(name = "lastUpdateDateTime")
	public Integer getLastUpdateDateTime() {
		return lastUpdateDateTime;
	}

	public void setLastUpdateDateTime(Integer lastUpdateDateTime) {
		this.lastUpdateDateTime = lastUpdateDateTime;
	}

	@JsonApiToOne
	@ManyToOne(fetch = FetchType.LAZY, cascade = CascadeType.REFRESH)
	@JoinColumn(name = "createuser_id", foreignKey = @ForeignKey(name = "null"))
	public User getCreateUser() {
		return createUser;
	}

	public void setCreateUser(User createUser) {
		this.createUser = createUser;
	}

	@JsonApiToOne
	@ManyToOne(fetch = FetchType.LAZY, cascade = CascadeType.REFRESH)
	@JoinColumn(name = "lastupdateuser_id", foreignKey = @ForeignKey(name = "null"))
	public User getLastUpdateUser() {
		return lastUpdateUser;
	}

	public void setLastUpdateUser(User lastUpdateUser) {
		this.lastUpdateUser = lastUpdateUser;
	}

	public WorkTimeSetting() {
	}

	@Column(name = "remark")
	public String getRemark() {
		return remark;
	}

	public void setRemark(String remark) {
		this.remark = remark;
	}

	@Column(name = "start_time_int")
	public Integer getStartTimeInt() {
		return startTimeInt;
	}

	public void setStartTimeInt(Integer startTimeInt) {
		this.startTimeInt = startTimeInt;
	}

	@Column(name = "ent_time_int")
	public Integer getEndTimeInt() {
		return endTimeInt;
	}

	public void setEndTimeInt(Integer endTimeInt) {
		this.endTimeInt = endTimeInt;
	}

}
